<?php

class RecomendacionPeer extends BaseRecomendacionPeer
{
	/**
	 * funcion que retorna un arreglo de objetos de recomendaciones no pedidas - pendientes -
	 */
	public static function getRecomendacionesPendientes(){
		$conn = Propel::getConnection();
		$subquery = "SELECT ".self::ID." FROM ".self::TABLE_NAME.", ".ItemspedidoPeer::TABLE_NAME." WHERE ".self::ID." = ".ItemspedidoPeer::IDRECOMENDACION;
		$query = "SELECT * FROM ".self::TABLE_NAME." WHERE ".self::ID." NOT IN ( $subquery );";
		$stm = $conn->prepare($query);
		$stm->execute();
		
		$recomendaciones = null;
		
		while( $recom = $stm->fetch(PDO::FETCH_OBJ) ){
			$recomendacion = new Recomendacion();
			$recomendacion->fromArray(
								array(
									'Id' => $recom->ID,
									'Codigoprofesor' => $recom->CODIGOPROFESOR,
									'Fecha' => $recom->FECHA,
									'Titulo' => $recom->TITULO,
									'Isbn' => $recom->ISBN,
									'Edicion' => $recom->EDICION,
									'Editorial' => $recom->EDITORIAL
								)
							);
			$recomendaciones[] = $recomendacion;
		}
		
		return $recomendaciones;
	}
}
